home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / misc / biology / treedraw.sit / Tree Draw Deck / card_11635.txt < prev    next >
Encoding:
Text File  |  1990-06-26  |  9.4 KB  |  200 lines

  1. -- card: 11635 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 8887
  5. -- name: 
  6.  
  7.  
  8. -- part 1 (button)
  9. -- low flags: 00
  10. -- high flags: A003
  11. -- rect: left=357 top=42 right=63 bottom=462
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 0 / 0
  14. -- text alignment: 1
  15. -- font id: 0
  16. -- text size: 12
  17. -- style flags: 0
  18. -- line height: 16
  19. -- part name: Analyze Stack
  20. ----- HyperTalk script -----
  21. --
  22. -- script: Stack Analyzer
  23. -- Author: Mike Swaine
  24. -- Vers 1.0 2/1/88
  25. -- From MacUser, May 1988, p. 82
  26. -- This script describes the structure of a hypercard stack
  27. --
  28. on mouseUp
  29.   -- initialize
  30.   global userName,showScripts, showEvents, analysis, theScripts
  31.   -- unsetLocks
  32.   set lockScreen to false
  33.   set lockMessages to false
  34.   set lockRecent to false
  35.   --
  36.   --put empty into card field 1
  37.   put empty into user
  38.   -- get name of stack
  39.   if userName is not empty then put ", " &word 1 of username into user
  40.   ask "Analyze what stack" &user &"?" with the short name of this stack
  41.   -- proceed if user gives name
  42.   if it is not empty then
  43.     put it into theStack
  44.     -- offer choces in report
  45.     put  theStack&".hc" into theFile
  46.     ask "Save analysis to file named?" with theFile
  47.     if it is not empty then put it into theFile
  48.     answer "Do message tracking?" with "Yes" or "No"
  49.     put (it="Yes") into showEvents
  50.     answer "Do script extraction?" with "Yes" or "No"
  51.     put (it="Yes") into showScripts
  52.     -- the report wwill be built in a container called analysis
  53.     -- start building with title
  54.     if user is not empty then put " for " &userName into user
  55.     put "Analysis of " &theStack &" stack " &user into analysis
  56.     if showEvents or showScripts then put " with" after analysis
  57.     if showEvents then put " message tracking" after analysis
  58.     if showEvents and showScripts then put " and" after analysis
  59.     if showScripts then put " script extraction" after analysis
  60.     put return &return after analysis
  61.     -- do som inits
  62.     setLocks true
  63.     -- now analyze stack
  64.     analyze theStack,0
  65.     -- now unlock
  66.     setLocks false
  67.     -- display & cleanup
  68.     put "Writing analysis to file "&theFile into message box
  69.     open file theFile
  70.     write analysis &theScripts &return &"End of analysis" to file theFile
  71.     put empty into analysis
  72.     put empty into theScripts
  73.     hide message box
  74.   end if
  75. end mouseUp
  76. --
  77. -- this handler is invoked by message setLockws
  78. on setLocks flag
  79.   -- locking keeps this stack in control
  80.   if flag then set cursor to 4 else pop card
  81.   if flag then set lockScreen to true else set lockScreen to false
  82.   if flag then set lockMessages to true else set lockMessages to false
  83.   if flag then set lockRecent to true else set lockRecent to false
  84.   if flag then push this card else set cursor to 1
  85. end setlocks
  86. --
  87. -- this handler does analysis
  88. -- uses recursion to dig through stack
  89. on analyze thing,lev
  90.   -- analyze a stack,back,card,fld or button
  91.   global analysis,showScripts,ShowEvents,theScripts
  92.   put the name of thing into itsName
  93.   -- skip self
  94.   if itsName contains "Analyze Stack" then exit analyze
  95.   -- give user some feedback
  96.   put "Now examining " &itsName
  97.   -- report the object
  98.   put indent(lev) &itsName &return after analysis
  99.   if lev < 2 then go to thing
  100.   put word 1 of itsName into object
  101.   -- determine what kind of components
  102.   if object="stack" then put "bkgnd,card" into sub
  103.   if object="bkgnd" or object="card" then put object &" field," &object &" button" into sub
  104.   -- if it's a card, say backgnd
  105.   if object="card" and lev=1 then
  106.     put indent(lev) &" of" after analysis
  107.     put the name of this bkgnd &return after analysis
  108.   end if
  109.   -- if user asked for scripts...
  110.   if showScripts then
  111.     put the script of thing into itsScript
  112.     if itsScript is not empty then
  113.       put return &"ΓÇó===ΓÇó===ΓÇó Script of " &itsName &return after theScripts
  114.       put itsScript &return after theScripts
  115.       put return &"Γêå===Γêå===Γêå" & return after theScripts
  116.     end if
  117.   end if
  118.   -- bug after this ....
  119.   -- if the user asked for message tracking...
  120.   if showEvents then
  121.     put the script of thing into itsScript
  122.     put the number of lines of itsScript into nlines
  123.     if nlines > 2 then
  124.       -- this takes time..
  125.       put "Now examining the script of " &itsName
  126.       put indent(lev) &"- handles these message(s):" &return after analysis
  127.       -- examine each line
  128.       repeat with i=1 to nlines
  129.         put line i of itsScript into linei
  130.         put word 1 of linei into word1
  131.         -- the word "on" signals handler
  132.         if (word1="on") then put indent(lev) &" " &(word 2 of linei) &return after analysis
  133.         -- words "pass" and "send" signal deviations
  134.         if (word1="pass") then put indent(lev) &" (which it passes)" &return after analysis
  135.         if (word1="send") then put indent(lev) &" (It sends message " &(word 2 of linei) &" to " &(word 4 of linei) &" )" &return after analysis
  136.       end repeat
  137.     end if
  138.   end if
  139.   -- determine what components object has
  140.   if lev<2 then
  141.     do "put the number of " &(item 1 of sub) &"s into n1"
  142.     do "put the number of " &(item 2 of sub) &"s into n2"
  143.     if n1<>1 then put "s" into s1 else put "" into s1
  144.     if n2<>1 then put "s" into s2 else put "" into s2
  145.     -- report components
  146.     if n1+n2>0 then
  147.       put indent(lev) &" contains " &n1 &" " &(item 1 of sub) after analysis
  148.       put s1 &" and " &n2 &" " &(item 2 of sub) &s2 &return after analysis
  149.       -- then for each kind..
  150.       repeat with i=1 to 2
  151.         do "put the number of " &(item i of sub) &"s into n"
  152.         -- and for each component...
  153.         repeat with j=1 to n
  154.           put (item i of sub) &" " &j into m
  155.           -- analyze IT
  156.           analyze m,lev+1
  157.         end repeat
  158.       end repeat
  159.     end if
  160.   end if
  161. end analyze
  162. --
  163. function indent level
  164. -- this produces a tab for indentation of recursion
  165. repeat with i=1 to level+1
  166.   put "  " after s -- 2 spaces
  167. end repeat
  168. return(s)
  169. end indent
  170.  
  171.  
  172.  
  173.  
  174. -- part contents for background part 6
  175. ----- text -----
  176.  
  177. NOTES ON THIS HYPERCARD IMPLEMENTATION OF TREE DRAWING.
  178.  
  179. THE  EXAMPLE TREES
  180. The 5S rRNA tree descriptions are taken from a haphazard (= random) selection of 27 of the 5.8S rRNA sequences stored in the Structural RNA section of GenBank.  These sequences were aligned with the Clustal multiple alignment program, which also produces a tree description based on pairwise similarities of the aligned sequences.  This is where the Clustal tree came from.  Then the aligned sequences were fed into DNAML from the Phylip package.  This resulted in another, noticeably different tree.  I have no comments on which is the "correct" or better tree.
  181.  
  182. The Clustal tree description uses _cumulative node lengths_,  rather than the internode lengths expected in the standard tree description described earlier, and used by the current DrawTree and DrawGram.  If I find the time, I'll change these to internode lengths before sending out.  If not, you will need to change them for meaningful use of the node lengths.
  183.  
  184. PLOT OUTPUT
  185. The plots are drawn in a separate card-sized window,  and a second, full 8x11" page,  plot is drawn but not displayed.   You are provided with a selection of function buttons: clip, print, file, and such.   The print and file buttons use the full 8x11 page plot.  You will want to choose landscape drawing mode (11x8 page) for these to fit on one page.  The plot file that is produced is a standard Mac PICT file, which you can edit with MacDraw II, SuperPaint, Canvas or other Mac object graphics editors.  Many of the plotgram and plotree options were not implemented as it is easier to get these trees to look the way you want with a graphics editor.  
  186.  
  187. Note: Your Mac must have installed the TIMES font, point sizes 9 and 12, to display the labels in these drawings properly.   9 point is used in the cardsized window, and 12 point on the full page file.    
  188.  
  189. The clip button copies the card-sized drawing to hypercard, and leaves it on the clipboard where you can paste it into another program.  Note that the plots are all in Quickdraw's vector/object graphics, but when clipped to a hypercard, it becomes bitmapped graphics (which cannot be resized or editted).
  190.  
  191. Also, these routines will commonly draw labels at any rotation they or you think are best.  However, the labels are displayed in the card window only with rotations of 0┬░, 90┬░, 180┬░ or 270┬░, as I haven't yet written a routine to draw text at all angles.  The true angle of rotation is stored in the drawing for use by the printer or drawing editor.  Rotated text will be displayed and manipulable by most of the professional Mac drawing programs.  I favor MacDraw II for editting these files.  You can select your prefered drawing program for the PICTure files that the hp2pict routine creates by editting the Hypercard script of the plot background.  There all of the routines which call the hp2pict XCMD are located, and the routine called "FilePict" lets you set the file creator of the resulting Mac PICTure.  "MDPL" is the MacDraw II signature, "SPNT" is for SuperPaint, "MDRW" is for MacDraw.
  192.  
  193. The plotgram and plotree (and now drawgram and drawtree) programs as originally written produce a set of plot commands for various hardware.  It proved too time consuming for me to insert the Mac quickdraw plot commands directly into these programs (many hassles with drawing frames of reference, and 1 wasted day), but I adapted an hp2pict translator from other uses fairly easily.  New versions of plotgram / plotree may be adapted to this deck by following the comments in the source included here.
  194.  
  195. -- Don Gilbert
  196.  
  197.  
  198. -- part contents for background part 1
  199. ----- text -----
  200. Notes on this Deck